﻿#region using statements

using Microsoft.Xna.Framework;

using NGen;
using NGen.Managers.GUI;
using NGen.Managers.GameState;

using Nuclex.UserInterface;
using Nuclex.UserInterface.Controls.Desktop;

using Psych.States;

#endregion

namespace Psych.GUILayouts
{
    /// <summary>
    /// 	The gui used in the menu stats
    /// </summary>
    public class GUIElementMenuStateLayout : GUIElement
    {
        #region local fields

        //buttons in the gui
        private readonly ButtonControl m_creditsButton = new ButtonControl();

        private readonly ButtonControl m_infoButton = new ButtonControl();

        private readonly ButtonControl m_playButton = new ButtonControl();

        private readonly ButtonControl m_quitButton = new ButtonControl();

        #endregion

        #region GUIElement implementation

        /// <summary>
        /// 	_Initialize this gui
        /// </summary>
        protected override void _Initialize()
        {
            //create and wire up the buttons, add then to the list of children 
            //which belong to this gui
            m_playButton.Bounds = new UniRectangle(new UniScalar(0.5f, -75.0f), new UniScalar(0.3f, 0.0f), new UniScalar(150), new UniScalar(0.05f, 0.0f));
            m_playButton.Text = "Play";
            m_playButton.Pressed += delegate
            {
                //anonymous method declaration
                GameEngine.GetService<IManagerGameState>().ChangeState(new GameStatePlay());
            };
            _Children.Add(m_playButton);

            m_infoButton.Bounds = new UniRectangle(new UniScalar(0.5f, -75.0f), new UniScalar(0.4f, 0.0f), new UniScalar(150), new UniScalar(0.05f, 0.0f));
            m_infoButton.Text = "How to Play";
            m_infoButton.Pressed += delegate { GameEngine.GetService<IManagerGUI>().AddElement(new GUIElementHelpWindow()); };

            _Children.Add(m_infoButton);

            m_creditsButton.Bounds = new UniRectangle(new UniScalar(0.5f, -75.0f), new UniScalar(0.5f, 0.0f), new UniScalar(150), new UniScalar(0.05f, 0.0f));
            m_creditsButton.Text = "Credits";
            m_creditsButton.Pressed += delegate
            {
                //anonymous method declaration
                GameEngine.GetService<IManagerGUI>().AddElement(new GUIElementCreditsWindow());
            };
            _Children.Add(m_creditsButton);

            m_quitButton.Bounds = new UniRectangle(new UniScalar(0.5f, -75.0f), new UniScalar(0.6f, 0.0f), new UniScalar(150), new UniScalar(0.05f, 0.0f));
            m_quitButton.Text = "Quit";
            m_quitButton.Pressed += delegate
            {
                //anonymous method declaration
                GameEngine.Exit();
            };
            _Children.Add(m_quitButton);
        }

        /// <summary>
        /// 	Update this gui
        /// </summary>
        /// <param name = "p_gameTime">snapshot of timing values</param>
        protected override void Update(GameTime p_gameTime)
        {
            //nothing to update
        }

        /// <summary>
        /// 	Cleanup this gui
        /// </summary>
        protected override void _Cleanup()
        {
            //no cleanup necessary outside of the normal memory deallocation
            //C# takes care of this via garbage collection
        }

        #endregion
    }
}